package com.sky.mapper;

import com.sky.dto.GoodsSalesDTO;
import com.sky.entity.OrderDetail;
import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@Mapper
public interface OrderDetailMapper {
    // 批量插入订单明细数据
    void insert(OrderDetail orderDetail);
    // 根据订单id分页查询订单明细
    @Select("select * from order_detail where order_id = #{id}")
    List<OrderDetail> pageQuery(Long id);
    @Select("select od.name,sum(od.number)number from order_detail od,orders o where od.order_id=o.id and o.status = 5 and o.order_time between #{begin} and #{end} group by od.name order by number desc limit 0,10")
    List<GoodsSalesDTO> getTop10(LocalDateTime begin, LocalDateTime end);

}
